//引入
import Vue from 'vue'
import Router from 'vue-router'
import Agent from '@/components/agent/agent'
import Contacts from '@/components/contacts/contact'
import Home from '@/components/home/home'
import Extension from '@/components/products/extension'
import Huoke from '@/components/products/huoke'
import Kelianke from '@/components/products/kelianke'
import Market from '@/components/products/market'
import Center from '@/components/personalCenter/personalCenter'
import Login from '@/components/login/login'
import Register from '@/components/login/register'
import ForgetPassword from '@/components/login/forgetPassword'
import RevisePassword from '@/components/login/revisePassword'
import Protocol from '@/components/protocol/protocol'
import Manager from '@/components/manager/manager'

Vue.use(Router);

//抛出组件
//第一个为默认显示
export default new Router({
  routes: [
    {
      path: '/',
      redirect:'/home'
    },
    {
      path: '/agent',
      name: 'Agent',
      component: Agent
    },{
      path: '/contacts',
      name: 'Contacts',
      component: Contacts
    },{
      path: '/home',
      name: 'Home',
      component: Home
    },{
      path: '/extension',
      name: 'Extension',
      component: Extension
    },{
      path: '/huoke',
      name: 'Huoke',
      component: Huoke
    },{
      path: '/kelianke',
      name: 'Kelianke',
      component: Kelianke
    },{
      path: '/market',
      name: 'Market',
      component: Market
    },{
      path: '/center',
      name: 'Center',
      component: Center
    },{
      path: '/login',
      name: 'Login',
      component: Login
    },{
      path: '/register',
      name: 'Register',
      component: Register
    },{
      path: '/forgetPassword',
      name: 'ForgetPassword',
      component: ForgetPassword
    },{
      path: '/revisePassword',
      name: 'RevisePassword',
      component: RevisePassword
    },{
      path: '/protocol',
      name: 'Protocol',
      component: Protocol
    },{
      path: '/manager',
      name: 'Manager',
      component: Manager
    }
  ],
  //每次跳转返回顶部
  scrollBehavior(to, from, savedPosition){
    if (savedPosition) {
      return savedPosition
    } else {
      return {x: 0, y: 0}
    }
  }
})
